package 力扣.位运算;

public class 两整数之和371 {
    public static void main(String[] args) {
        int s = getSum(-14, 16);
        System.out.println(Integer.toBinaryString(-14));
        System.out.println(s);
    }
    public static int getSum(int a, int b) {
          int l1 = a ^ b; //异或运算不进位 要想进位用与运算
          int l2 = (a & b) << 1;//与运算进位 但是应该右移一位才能真正表示进位数
          while (l2 != 0) {//直到进位为零
              int te = l1;
              l1 = l1 ^ l2;
              l2 = (te & l2) << 1;
          }
          return l1;
    }

}
